/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.IOException;
import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/**
 *
 * @author zimi
 */
public class Category {

    private int id;

    private String name;

    public Category(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public Category(KXmlParser parser) throws IOException, NumberFormatException, XmlPullParserException {
        while (parser.nextTag() != XmlPullParser.END_TAG) {
            parser.require(XmlPullParser.START_TAG, null, null);
            String innerTagName = parser.getName();
            String innerTagText = parser.nextText();
            if (innerTagName.equals("id")) {
                this.id = Integer.parseInt(innerTagText);
            }
            if (innerTagName.equals("name")) {
                this.name = innerTagText;
            }
            parser.require(XmlPullParser.END_TAG, null, null);
        }
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
